<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Panel extends Model
{
    protected $table = 'cqe_panel';

    public function student()
    {
        return $this->belongsTo(Student::class);
    }

    protected static function boot() {
        parent::boot();

        static::saving(function ($model) {
            $model->students = implode(',', $model->students);
        });
    }

    public function semester()
    {
        return $this->belongsTo(Semester::class);
    }

    public function class()
    {
        return $this->belongsTo(Grade::class);
    }
}
